<?php
	$db = mysql_connect("localhost", "httpd", "");

	mysql_select_db("phylotype",$db);

	$title = "HIV-1 Phylotypes Description";
	
	$phylotypeID = $_GET['phylotype'];
?>


<html>
	<head>
		<?php echo("<title>$title</title>\n"); ?>
		<link href="../evolve.css" rel="stylesheet" media="screen">
	</head>

<body>

<?php 
	include("evolve.inc");
	
	drawHeader();
	
	echo openPageBody();
	echo openColumn();

	if ($phylotypeID) {
		$result1 = mysql_query("SELECT * FROM Phylotypes WHERE id=$phylotypeID ORDER BY name ASC",$db);	
	
		if ($phylotype = mysql_fetch_array($result1)) {
			$id = $phylotype["id"];
			$name = $phylotype["name"];
			$parentID = $phylotype["parent"];
			$description = $phylotype["description"];
			$descriptiontool = $phylotype["descriptiontool"];
			$losclassification = $phylotype["losclassification"];
			$geographic = $phylotype["geographic"];
			$transmission = $phylotype["transmission"];
			$epidemiosign = $phylotype["epidemiosign"];
			$losdescription = $phylotype["losdescription"];

		
			
			echo openBox("white-box");
			echo boxTitle($id.":".$name);
			
			echo openBoxRow();
			echo '<br><p><b>Description I: </b>'.$description.'</p>';
			echo '<p><b>Description II: </b>'.$descriptiontool.'</p>';
			echo '<p><b>Geography: </b>'.$geographic.'</p>';
			echo '<p><b>Transmission route: </b>'.$transmission.'</p>';
			echo '<p><b>Epidemiological significance: </b>'.$epidemiosign.'</p>';
			echo '<br><p><b>Robertson 2000 / Los Alamos classification: </b>'.$losclassification.'</p>';
			echo '<p><b>Description on Los Alamos: </b>'.$losdescription.'</p>';
			echo closeBoxRow();
			echo closeBox();
				
			
			
			echo openBox("box-info");
			echo boxTitle("Reference Strains");
			
			echo openBoxRow();
			
			$result4 = mysql_query("SELECT * FROM Strains WHERE phylotype=\"$phylotypeID\" ORDER BY id ASC",$db);	
	
		
			if ($phylotype4 = mysql_fetch_array($result4)) {
				echo '<br><p><dl><b>For details on strains click on the sequence name or genome map</b></p></dl>';
				do {
					$id4 = $phylotype4["id"];
					$seqname4 = $phylotype4["seqname"];
					$regaref4 = $phylotype4["regaref"];
					$accession4 = $phylotype4["accession"];
					$image4 = $phylotype4["image"];
					
			echo '<p><b>Sequence Name: <a href="http://www.ncbi.nlm.nih.gov/sites/entrez?db=nucleotide&cmd=&term='.$accession4.'">'.$seqname4.'</b></a></p>';
			echo '</b><p><a href="http://hivweb.sanbi.ac.za/rega-genotype/genotype.php?cmd=details&sequence='.$regaref4.'&job=phylotype"> <img src="/phylotype/images/genome_'.$image4.'p'.$id.'.png"></a></b></p>';
		
			} while ($phylotype4 = mysql_fetch_array($result4));
				echo '<p><small><i>Genome figures colored by bootscan analysis using REGA HIV Subtyping tool.</i></small></p>';
			} else {
				echo "<i>None defined</i>";	
			}

			
			echo closeBoxRow();
			echo closeBox();






			
			echo openBox("box-info");
			echo boxTitle("Decendant Phylotype");
			
			echo openBoxRow();			
			$result2 = mysql_query("SELECT * FROM Phylotypes WHERE parent=\"$phylotypeID\" ORDER BY name ASC",$db);	
	
		
			if ($phylotype2 = mysql_fetch_array($result2)) {
				echo '<p><dl>';
				do {
					$id2 = $phylotype2["id"];
					$name2 = $phylotype2["name"];
					$description2 = $phylotype2["descriptiontool"];
					
					echo '
						<dt><b><a href="phylotypes.php?phylotype='.$id2.'">'.$name2.'</a></b></dt>
					';

					echo '<dd>'.$description2.'</dd>';
				
				} while ($phylotype2 = mysql_fetch_array($result2));
				echo '</dl></p>';
			} else {
				echo "<i>None defined</i>";	
			}
			echo closeBoxRow();
			echo closeBox();
			
			echo openBox("box-info");
			echo boxTitle("Parent Phylotypes");

			echo openBoxRow();
			$result2 = mysql_query("SELECT * FROM Phylotypes WHERE id=\"$parentID\"",$db);	
			
			if ($phylotype2 = mysql_fetch_array($result2)) {
				echo '<p><dl>';
				do {
					$id2 = $phylotype2["id"];
					$name2 = $phylotype2["name"];
					$description2 = $phylotype2["description"];
					
					echo '
						<dt><b><a href="phylotypes.php?phylotype='.$id2.'">'.$name2.'</a></b></dt>
					';

					echo '<dd>'.$description2.'</dd>';
				
				} while ($phylotype2 = mysql_fetch_array($result2));
				echo '</dl></p>';
			} else {
				echo "<i>None defined</i>";	
			}
			echo closeBoxRow();
			echo closeBox();
		} else {
			echo "Unknown phylotype id: ".$phylotypeId;	
		}
	} else {
		$result1 = mysql_query("SELECT * FROM Phylotypes ORDER BY name ASC",$db);	
	
		if ($phylotype = mysql_fetch_array($result1)) {
		
			echo '<dl>';
			do {
				$id = $phylotype["id"];
				$name = $phylotype["name"];
				$descriptiontool = $phylotype["descriptiontool"];
			
				echo '
					<dt><b><a href="phylotypes.php?phylotype='.$id.'">'.$name.'</a></b></dt>
				';

				echo '<dd>'.$descriptiontool.'<br>';
				
			} while ($phylotype = mysql_fetch_array($result1));
			echo '</dl>';
		} else {
			echo "No phylotypes in the database";	
		}
/*		$result1 = mysql_query("SELECT * FROM Phylotypes WHERE parent=0 ORDER BY name ASC",$db);	
	
		if ($phylotype = mysql_fetch_array($result1)) {
		
			echo '<dl>';
			do {
				$id = $phylotype["id"];
				$name = $phylotype["name"];
				$description = $phylotype["description"];
				
				if ($id == $phylotypeID) {
					echo '
						<dt><b><a href="phylotypes.php"><img src="images/disclosureOpen.png"> '.$name.'</a></b></dt>
					';
	
					echo '<dd>'.$description.'<br>';
					
					$result2 = mysql_query("SELECT * FROM Phylotypes WHERE parent=\"$phylotypeID\" ORDER BY name ASC",$db);	
				
					if ($phylotype2 = mysql_fetch_array($result2)) {
						echo '<dl>';
						do {
							$id2 = $phylotype2["id"];
							$name2 = $phylotype2["name"];
							$description2 = $phylotype2["description"];
							
							echo '
								<dt><i>'.$name2.'</i></dt>
							';
	
							echo '<dd>'.$description2.'</dd>';
						
						} while ($phylotype2 = mysql_fetch_array($result2));
						echo '</dl>';
					} else {
						echo "Unknown phylotype id";	
					}
					echo '</dd>';
	
			
				} else {
					echo '
						<dt><b><a href="phylotypes.php?phylotype='.$id.'"><img src="images/disclosureClosed.png"> '.$name.'</a></b></td>
						';
					echo '<dd>'.$description.'</dd>';
				}
			} while ($phylotype = mysql_fetch_array($result1));
			echo '</dl>';
		} else {
			echo "No phylotypes in the database";	
		}
		*/
	}
	echo closeColumn();
	echo closePageBody();

	drawFooter("Andrew Rambaut"); 
	closeDocument();
?>
       
